<?php

interface Decorator {
    function render();
    function view();

}
/**
 * Description of selfDecor
 *
 * @author Trunghpb
 */
class  selfDecor implements Decorator {
    private $params = array();
    private $tplPath = '';
    private $tplName = '';
    public function addParam() {

    }
    public function removeParam() {

    }

    public function setPath($path){
        $this->tplPath = $path;
        $lastChar = substr($this->tplPath, strlen($this->tplPath) - 1);
        if ($lastChar != '\\' ||  $lastChar != '/') {
            $this->tplPath.='\\';
        }
    }
    public function setTpl($templ){

        $this->tplName = $templ.'.php';
    }

    public function getTplFile(){
        return $this->tplPath.$this->tplName;
    }

    public function render() {
        ob_start();
        extract($this->params);
        include $this->path;
        $this->result = ob_get_contents();
        ob_end_clean();
        return $this->result;

    }
    public function view() {
        echo $this->render();
    }


}
?>
